﻿using System;
using System.Globalization;

namespace Halk.Utils
{
   public class TimeHelper
    {
       public static int GetDateInt()
       {
           var dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
           var dtNow = DateTime.Parse(DateTime.Now.ToString(CultureInfo.InvariantCulture));
           TimeSpan toNow = dtNow.Subtract(dtStart);
           string timeStamp = toNow.Ticks.ToString(CultureInfo.InvariantCulture);
           timeStamp = timeStamp.Substring(0, timeStamp.Length - 7);
           return int.Parse(timeStamp);
       }

       public static DateTime GetDateTime()
       {
           const string timeStamp = "1176686120";
           DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
           long lTime = long.Parse(timeStamp + "0000000");
           var toNow = new TimeSpan(lTime);
           DateTime dtResult = dtStart.Add(toNow);
           return dtResult;
       }
    }
}
